// ajaxClass -- XMLHttp Object Pool and XMLHttp chunnel Pool
// == written by Apple <zysp322@gmail.com> ===
// == Copyright (C) 2006 Apple Blog - http://www.applelife.cn ==
//document.domain='.utvchina.com';
var httppic = 'http://flv.utvchina.com/video/';
//httppic = 'http://192.168.1.66/up/pic/';
var httpflv = "http://flv.utvchina.com/video/";
var httprflv = "http://rec.utvchina.com/";

/*function ResumeError() {
return true;
}
window.onerror = ResumeError;*/

var Request = new function(){

this.pool = new Array();

this.getXMLHttp = function (chunnel)
{
	
 if(chunnel != null)
 {
  for (var a = 0; a < this.pool.length; a++)
  {
   if(this.pool[a]["chunnel"] == chunnel)
   {
	if(this.pool[a]["obj"].readyState == 0 || this.pool[a]["obj"].readyState == 4)
    {
     return this.pool[a]["obj"];
    }
	else 
	{
      return "busy";
	}
   }
  }
  
  this.pool[this.pool.length] = new Array();
  this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp();
  this.pool[this.pool.length - 1]["chunnel"] = chunnel;
  return this.pool[this.pool.length - 1]["obj"];
 
 }
	
 for (var i = 0; i < this.pool.length; i++)
 {
  if (this.pool[i]["obj"].readyState == 0 || this.pool[i]["obj"].readyState == 4)
  {
   return this.pool[i]["obj"];
  }
 }
 
 this.pool[this.pool.length] = new Array();
 this.pool[this.pool.length - 1]["obj"] = this.createXMLHttp();
 this.pool[this.pool.length - 1]["chunnel"] = "";
 return this.pool[this.pool.length - 1]["obj"];

}

this.createXMLHttp = function ()
{
 
 if(window.XMLHttpRequest)
 {
  var xmlObj = new XMLHttpRequest();
 } 
 else 
 {
  var MSXML = ['Microsoft.XMLHTTP', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP','Microsoft.XMLDOM'];
  for(var n = 0; n < MSXML.length; n++)
  {
   try
   {
    var xmlObj = new ActiveXObject(MSXML[n]);        
    break;
   }
   catch(e)
   {
   }
  }
 } 
 
 return xmlObj;

}

this.reSend = function (url,data,callback,n,chunnel)
{
 var objXMLHttp = this.getXMLHttp(chunnel)
 
 if(typeof(objXMLHttp) != "object")
 {
   return ;
 }
 
 url += (url.indexOf("?") >= 0) ? "&nowtime=" + new Date().getTime() : "?nowtime=" + new Date().getTime();

 if(data == "")
 {
  objXMLHttp.open('GET' , url, true);
  objXMLHttp.send(null);
 }
 else 
 { 
  objXMLHttp.open('POST' , url, true);
  objXMLHttp.setRequestHeader("Content-Length",data.length); 
  objXMLHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  objXMLHttp.send(data);
 }

 if(typeof(callback) == "function" )
 {
  objXMLHttp.onreadystatechange = function ()
  {
   if (objXMLHttp.readyState == 4)
   {
    if(objXMLHttp.status == 200 || objXMLHttp.status == 304)
    {
		if (n != null)
		 callback(objXMLHttp,n)
	    else
		 callback(objXMLHttp)
    }
    else
    {
     /*alert("Error loading page\n"+ objXMLHttp.status +":"+ objXMLHttp.statusText);*/
	 /*document.location.href=["/"];*/
	 	callback(null)
    }
   }
  }
 }

}

}

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
if (object != "[object]"){ 
setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
return;
}
clearTimeout(nereidFadeTimers[object.sourceIndex]);
diff = destOp-object.filters.alpha.opacity;
direction = 1;
if (object.filters.alpha.opacity > destOp){
direction = -1;
}
delta=Math.min(direction*diff,delta);
object.filters.alpha.opacity+=direction*delta;
if (object.filters.alpha.opacity != destOp){
nereidFadeObjects[object.sourceIndex]=object;
nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
}
}

function rssret()
{
	this.items = "";
	this.title = "";
	this.txt = "";
	this.lastupdate = "";
	this.description = "";

	this.item_title = new Array();
	this.item_link = new Array();
	this.item_url = new Array();
	this.item_file = new Array();
	this.item_txt = new Array();
	this.item_uptime = new Array();
	this.item_label = new Array();//category
	this.item_author = new Array();
	this.item_playtime = new Array();
	this.item_vid = new Array();
	this.item_uid = new Array();
	this.item_cid = new Array();
	this.item_www_cod = new Array();
	this.item_turn = new Array();
	this.item_rec = new Array();
	this.item_pl = new Array();
	this.item_ll = new Array();
	this.item_collection = new Array();
	this.item_pf = new Array();
	
	this.news_title = new Array();
	this.news_link = new Array();
	this.news_description = new Array();
	this.news_guid = new Array();
	this.news_author = new Array();
	this.news_category = new Array();
	this.news_pubDate = new Array();
	this.news_video_flag = new Array();
	this.news_pic_flag = new Array();
	
	
	this.rss_news_obj = function (obj)
	{
		var item_rss;
		var rssDom = obj.responseXML;
		var root = rssDom.getElementsByTagName("channel")[0];
		this.title = root.getElementsByTagName("title")[0];
		this.items = root.getElementsByTagName("item");
		for(i=0;i<this.items.length;i++)
		{
			item_rss=this.items[i];
			this.news_title[i] = item_rss.getElementsByTagName("title")[0].firstChild.nodeValue;
			this.news_link[i] = item_rss.getElementsByTagName("link")[0].firstChild.nodeValue;
			this.news_description[i] = item_rss.getElementsByTagName("description")[0].firstChild.nodeValue;
			this.news_guid[i] = item_rss.getElementsByTagName("guid")[0].firstChild.nodeValue;
			this.news_author[i] = item_rss.getElementsByTagName("author")[0].firstChild.nodeValue;
			this.news_category[i] = item_rss.getElementsByTagName("category")[0].firstChild.nodeValue;
			this.news_pubDate[i] = item_rss.getElementsByTagName("pubDate")[0].firstChild.nodeValue;
			this.news_video_flag[i] = item_rss.getElementsByTagName("video_flag")[0].firstChild.nodeValue;
			this.news_pic_flag[i] = item_rss.getElementsByTagName("pic_flag")[0].firstChild.nodeValue;
		}
	}
	this.rssobj = function (obj)
	{
		var item_rss;
		var rssDom = obj.responseXML;
		var root = rssDom.getElementsByTagName("channel")[0];
		this.title = root.getElementsByTagName("title")[0].firstChild.nodeValue;		
		this.description = root.getElementsByTagName("description")[0].firstChild.nodeValue;
		if (!this.description) this.description = "没有内容";
		this.items = root.getElementsByTagName("item");
		for(i=0;i<this.items.length;i++)
		{
			item_rss=this.items[i];
			this.item_title[i] = item_rss.getElementsByTagName("title")[0].firstChild.nodeValue;
			this.item_link[i] = item_rss.getElementsByTagName("link")[0].firstChild.nodeValue;
			this.item_url[i] = item_rss.getElementsByTagName("upload_date")[0].firstChild.nodeValue;
			this.item_file[i] = item_rss.getElementsByTagName("upload_name")[0].firstChild.nodeValue;
			this.item_txt[i] = item_rss.getElementsByTagName("description")[0].firstChild.nodeValue;
			this.item_uptime[i] = item_rss.getElementsByTagName("Broadcast_time")[0].firstChild.nodeValue;
			this.item_label[i] = item_rss.getElementsByTagName("category")[0].firstChild.nodeValue;
			this.item_author[i] = item_rss.getElementsByTagName("author")[0].firstChild.nodeValue;
			this.item_playtime[i] = item_rss.getElementsByTagName("playtime")[0].firstChild.nodeValue;
			this.item_vid[i] = item_rss.getElementsByTagName("guid")[0].firstChild.nodeValue;
			this.item_uid[i] = item_rss.getElementsByTagName("user_code")[0].firstChild.nodeValue;
			this.item_cid[i] = item_rss.getElementsByTagName("channel_code")[0].firstChild.nodeValue;
			
			/*this.item_www_cod[i] = item_rss.getElementsByTagName("regional_type")[0].firstChild.nodeValue;
			this.item_turn[i] = item_rss.getElementsByTagName("turn_flag")[0].firstChild.nodeValue;*/
			this.item_rec[i] = item_rss.getElementsByTagName("record_flag")[0].firstChild.nodeValue;
			this.item_pl[i] = item_rss.getElementsByTagName("pl_sum")[0].firstChild.nodeValue;
			this.item_ll[i] = item_rss.getElementsByTagName("viewTimes")[0].firstChild.nodeValue;
			this.item_collection[i] = item_rss.getElementsByTagName("collection_sum")[0].firstChild.nodeValue;
			this.item_pf[i] = item_rss.getElementsByTagName("globalRank")[0].firstChild.nodeValue;
		}
	}
}

String.prototype.Trim  =  function()  
{  
  return  this.replace(/(^\s*)|(\s*$)/g,  "");  
}  

String.prototype.LTrim  =  function()  
{  
return  this.replace(/(^\s*)/g,  "");  
}  

String.prototype.RTrim  =  function()  
  {  
  return  this.replace(/(\s*$)/g,  "");  
}
function bcfocus(name)
{
   var oInput = document.all[name];
   var oRange = oInput.createTextRange();
   oRange.move('character', oInput.value.length);
   oRange.moveEnd('character');
   oRange.select();
}
function _ck(obj)
{
	if(!obj.value) $('err_'+obj.id).style.display = 'block';
	else $('err_'+obj.id).style.display = 'none';
}
function err_src(src)
{
	src.src='/pic/photo.jpg';
}
function js_err(id)
{
	var provinces = new Array(
	"请输入您的用户名或密码.",//0
	"欢迎<strong class=Orange>" + $("login_name").value.Trim() + "</strong>的来访",//1
	"用户名或密码错误，请重新登录.",//2
	"您的系统记录有误,请重新登录.",//3
	"请不要重复登录",//4
	"");
	return provinces[id];
}

var pltsPop=null;
var pltsoffsetX = 3;
var pltsoffsetY = 20;
var pltsTitle="";
fontsize="12px";
fontfamily="Lucida Grande";
fontcolor="#000000";
bgcolor="#E0F4FD";
bordercolor="#BCE9FE";
document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText {  background-color: " + bgcolor + ";font-size:" + fontsize + ";font-family:" + fontfamily + ";color:" + fontcolor + "; border: 1px " + bordercolor + " solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px;  padding-top: 4px; padding-bottom: 2px;}");
document.write("</style>");
document.write('<div id=pltsTipLayer style="display: none;position:absolute;z-index:1000;" class="cPopText">loading...</div>');
var ax_ts=document.getElementById("pltsTipLayer");
function pltsinits()
{
    document.onmouseover   = plts;
    document.onmousemove = moveToMouseLoc;
}
function plts(e)
{
	if(e){o=e.target;MouseX=e.pageX;MouseY=e.pageY}
	else{o=event.srcElement;MouseX=event.x;MouseY=event.y}

    if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
    if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
	
    pltsPop=o.dypop;
	ax_ts.style.width = null;
	if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
	{
		ax_ts.style.left=-1000;
		ax_ts.style.display='block';
		ax_ts.innerHTML=pltsPop;
		document.getElementById("pltsTipLayer").style.width=Math.min(ax_ts.clientWidth-8,document.body.clientWidth/2);
		moveToMouseLoc(e);
		return true;
	}
    else
    {
    	ax_ts.innerHTML='';
      	ax_ts.style.display='none';
       	return true;
    }
}

function moveToMouseLoc(e)
{
if(e){MouseX=e.pageX;MouseY=e.pageY;}else{MouseX=event.x;MouseY=event.y;}
if(ax_ts.innerHTML=='')return true;
	var popHeight=ax_ts.clientHeight;
	var popWidth=ax_ts.clientWidth;
	if(MouseY+pltsoffsetY+popHeight>document.body.clientHeight)
	{
	  	popTopAdjust=-popHeight-pltsoffsetY*1.5;
	}
	 else
	{
	   popTopAdjust=-popHeight-pltsoffsetY*1.5;
	}
	if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth)
	{
		popLeftAdjust=-popWidth-pltsoffsetX*2;
	}
	else
	{
		popLeftAdjust=0;
	}
	ax_ts.style.left=MouseX+pltsoffsetX+document.body.scrollLeft+popLeftAdjust+'px';
	if (navigator.userAgent.indexOf("MSIE")<=0){
		ax_ts.style.top=MouseY+pltsoffsetY+popTopAdjust+'px';
	}
	else{
	ax_ts.style.top=MouseY+pltsoffsetY+document.documentElement.scrollTop+popTopAdjust;
	}
  	return true;
}
pltsinits();

function insertFlash(elm, url, w, h) {
if (!document.getElementById(elm)) return;
var str = '';
str += '<object width="'+ w +'" height="'+ h +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0">';
str += '<param name="movie" value="'+ url +'">';
str += '<param name="wmode" value="transparent">';
str += '<param name="quality" value="autohigh">';
str += '<embed width="'+ w +'" height="'+ h +'" src="'+ url +'" quality="autohigh" wmode="transparent" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
str += '</object>';
document.getElementById(elm).innerHTML = str;
}

function insertFlash_pop(elm, url, w, h) {
if (!document.getElementById(elm)) return;
var str = '';
str = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+ w +'" height="'+ h +'" id="videoFullscreen" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="true"/><param name="movie" value="'+ url +'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+ url +'"/><embed src="'+url+'" quality="high" bgcolor="#ffffff" width="'+ w +'" height="'+ h +'" name="videoFullscreen" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
document.getElementById(elm).innerHTML = str;
}

function Go(obj,n,i) 
{ 
	var setobj,objtmp;
	switch(i)
	{
		case 1: setobj = 'Orange,Gray,,'; break;
		case 2: setobj = 'botton1 f13 Blue,botton f13 Gray,,'; break;
		case 3: setobj = 'Blue,Gray,,'; break;
		case 4: setobj = 'Blue,Gray,,'; break;
		case 5: setobj = 'Blue,Gray,,'; break;
		case 6: setobj = 'Blue,Gray,,'; break;
		case 7: setobj = 'Blue,Gray,,'; break;
		default:setobj = '';
	}
	setobj = setobj.split(',');
	for(var z=1;z<=n;z++)
	{
		objtmp = setobj[0]+z;
		if(obj.id==objtmp)
		{
			obj.className = setobj[0];			
		}
		else
		{
			document.getElementById(setobj[0] + z).className = setobj[1];
		}
	}
}